package com.iversonx.example_1.controller.v2;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import java.util.List;

@Component
public class PrizeServiceFactory {
    @Autowired
    private List<PrizeService> prizeServices;
    public PrizeService getPrizeService(Integer prizeType) {
        for(PrizeService prizeService : prizeServices) {
            if(prizeService.support(prizeType)) {
                return prizeService;
            }
        }
        throw new RuntimeException("不存在的商品服务类型");
    }
}
